package model;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

public class TestDay extends TestCase {

	private Day day;
	private Food oroSaiwa, wasa, meat;
	private Training swim, run;
	
	@Before
	public void setUp() {
		day = new Day("20130101");
		oroSaiwa = new Food(4, 0.4, 0.5, "1 biscuit");
		wasa = new Food(6, 1, 0.1, "1 slice");
		meat = new Food(0.006, 0.198, 0.068, "1g");
		swim = new Training("Swim, 1h", 600, new int[]{102,16});
		run = new Training("Run, 50'", 872, new int[]{});
		day.addFood(oroSaiwa, 16);
		day.addFood(wasa, 2);
		day.addFood(meat, 200);		
		day.addTraining(swim);
		day.addTraining(run);
	}
	
	@Test
	public void testDailyCalories() {		
		/*
		 * cal = 354 + 58 + 286 - 600 + 102 + 16 - 872
		 * cal = -656
		 */	
		assertEquals(day.getCaloriesEaten(), 698);
		assertEquals(day.getCaloriesTrainings(), -1354);
		assertEquals(day.getCalories(), -656);
	}
	
	@Test
	public void testRatios() {
		/*
		 * cal eaten = 697
		 * carboCal eaten = 4*16*4 + 6*2*4 + 0,006*200*4 = 256 + 48 + 4,8 = 308,8
		 * proteinCal eaten = 0,4*16*4 + 1*2*4 + 0,198*200*4 = 25,6 + 8 + 158,4 = 192
		 * fatCal eaten = 0,5*16*9 + 0,1*2*9 + 0,068*200*9 = 72 + 1,8 + 122,4 = 202,2
		 * 
		 * ratioCarbo = 308,8*100/697 = 44,3 %
		 * ratioProtein = 192*100/697 = 27,5 %
		 * ratioFat = 122,4*100/697 = 29,0 %
		 */
		
		//double calEaten = day.getCaloriesEaten();
		
		
	}

}
